package com.dragon.jdbc;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;

/**
 * jdbc Driver 测试案例
 *
 * @author dragon
 * @since 2019/9/25 00:18
 */
public class DriverDemo {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException,
            InstantiationException, SQLException {
        // 注册驱动
        Driver driver =(Driver) Class.forName("com.mysql.jdbc.Driver").newInstance();
        String url = "jdbc:mysql://localhost/mybatis_test";
        // 接受一个url,测试连接的url是否正确
        boolean isTrue = driver.acceptsURL(url);
        System.out.println("url是否正确:" + isTrue);
        Properties properties = new Properties();
        properties.setProperty("user", "root");
        properties.setProperty("password", "dragon4369");
        // 获取连接
        Connection connection = driver.connect(url, properties);
        System.out.println("连接对象：" + connection);

    }
}
